Add an ADO Database Data Source

  • When connecting to a remote ADO Database data source, the connection to the remote database is made from the App Server. By default, the App Server runs under the Local System Account which means that if you want to use Windows Authentication to log in to the remote database, it will be the System Account which is being authenticated. However, the System Account has no username/password with which to be authenticated and so you may need to configure your login in some other way.
    For example, if the remote data source is a SQL database, and the SQL instance is running on a different server to that running the App Server, you can configure SQL to authenticate against the machine name of the server running the App Server instead.

    If the remote data source is a SQL database and you are running both App Server and SQL Server on the same machine you should note that from SQL Server 2012 onwards, the Local System Account is no longer automatically enabled as a login nor is it made a member of the sysadmin server role within SQL Server. Therefore, when running SQL Server and App Server on the same machine, if you want to connect to the SQL Server using Windows Authentication, you will need to manually configure your SQL Server to provide the required access permissions for the System Account or grant it the sysadmin server role.

 

To add an ADO database data source:

  1. Choose New Data Source from the Project group of the Ribbon's Home tab. This will display a sub-menu of the different data source types. Choose ADO Database.

  2. The New ADO Database Data Source dialog box will be displayed.

    Enter a name for this Data Source in the Name field. This name is used to reference the Data Source within your Project.

  3. If you know the correct connection string required to connect to the remote database, enter it in the Connection String field. Alternatively click on the browse button, Picture showing the Browse button., to display the Data Link Properties wizard:

    Picture showing the Data Link Properties wizard.

    The database providers listed here may vary from that shown above, depending upon the database drivers installed on the machine.

    Select the type of database you want to connect to on the Provider tab. Digitise Apps can connect to Microsoft SQL Server databases or any other database which can accept ANSI SQL queries.

    By default, Digitise Apps connects to remote SQL Server databases using a Microsoft OLE DB client. If the database is hosted by an instance of SQL Server running on a machine which has the TLS 1.0 and 1.1 security protocols DISABLED, you will either need to update the OLE DB driver for SQL Server to the latest version, which supports TLS 1.2, or connect using a SQL Server Native Client driver instead. The choice is yours – contact your database administrator for advice.

    If you don’t know whether TLS 1.0 and 1.1 have been disabled or not, try using the default Microsoft OLE DB client first (see below) and if you are able to connect to the database, the TLS protocols are enabled and you can continue to use this driver. If, on the other hand, at any point you get SSL Security errors or cannot connect to the Configuration Database, the TLS protocols may be disabled and you should try using the updated OLE DB driver or SQL Server Native Client driver instead.

    If you decide to update the OLE DB driver, you will need to update it on any machine running an App Server which will want to connect to this remote database, which includes your development PCs. At the time of writing, you can download the update, Microsoft OLE DB Driver 18 for SQL Server, from Microsoft’s web site:

     

    https://www.microsoft.com/en-us/download/details.aspx?id=56730

     

    After downloading the installer, you simply run it and select to install the ODBC Driver Client Components.

    If you decide to use the SQL Server Native Client instead, at the time of writing, you can download the latest version from Microsoft’s web site, if you need it:

     

    https://www.microsoft.com/en-us/download/details.aspx?id=50402

     

    Whichever driver you choose to use, if at any point during configuring the connection string you get an error message something like this:

    Picture showing Microsoft Data Link Error indicating problem with database driver.

    you will need to re-install the driver. You may need to uninstall the existing driver before reinstalling it.

    To specify the connection string:

    1. If the machine on which you are running the SQL Server has TLS 1.0 and TLS 1.1 security protocols enabled, under the Provider tab select Microsoft OLE DB Provider for SQL Server.

      Where TLS 1.0 and 1.1 have been disabled, and you have upgraded the OLE DB driver, you should select Microsoft OLE DB Driver for SQL Server under the Provider tab.

      Alternatively, where TLS 1.0 and 1.1 have been disabled and you want to use the SQL Server Native Client, you can select SQL Server Native Client 11.0 under the Provider tab and use this provider instead of the OLE DB Driver.

      If you don’t know whether TLS 1.0 and 1.1 have been disabled or not, try using the Microsoft OLE DB Provider for SQL Server first and if you get SSL Security errors or cannot connect to the target database, either download the later OLE DB driver and reconfigure the connection string to use this driver or reconfigure the connection string to use the SQL Server Native Client 11.0 instead.

      • If your SQL Server is configured to use an availability group, for example, for backup/failover purposes, you should select Microsoft OLE DB Driver for SQL Server here. This will allow you to specify relevant initialisation properties under the All tab, if required.

    2. Once you have selected a Provider, click Picture showing the Next Button. or click on the Connection tab.

    3. The options available on the Connection tab, depend upon the driver you have selected under the Provider tab:

     

    Once you have successfully connected to the database server instance, click on the OK button to complete specifying the connection string.

  4. You will return to the New ADO Database Data Source dialog box.

    If your database includes views as well as tables and you want to use these to select data items to be mapped within your app, select Include Views as well as Tables.

    The Enter Schema Tables Manually option allows you to manually enter which tables within the remote database contain the data items you want to use within your Digitise app. If you leave this option unchecked, Digitise Apps will display a list of all the tables in your specified database and allow you to choose the relevant ones for your app from the list.

    Click on the OK button to continue.

  5. If you didn't select Enter Schema Tables Manually in the New ADO Database Data Source dialog box, the Select Tables dialog box will be displayed.

    On the right-hand side of this dialog box a list of all the tables in your specified database will be displayed. Select the tables which contain data you want to use within your app and use the << Add << button to move them into the left-hand list. The << Add All << button will add all the available tables into the left-hand list and the >> Remove >> and >> Remove All >> buttons can be used to deselect tables and return them to the right-hand Available Tables list. The Tables you select here will be displayed in the Data Source Schema diagram for this database which you will use later to indicate which data items you want to use within your app. Click on the OK button when you have selected all the required tables.

    If you did select Enter Schema Tables Manually in the New ADO Database Data Source dialog box, the Select Tables dialog box will be displayed instead allowing you to type in the names of the required tables from the remote database.

    Type the name of the first table in the Name field and then choose the << Add << button to add it to the Selected Tables list. Enter the names of any other tables you want to use from the remote database in the same way and then click on the OK button when you have finished.

    • You can add or remove tables from the Data Source Schema after adding the Data Source by right-clicking on the Data Source in the Data Sources Pane and choosing Update Schema from the context menu displayed. This option will redisplay the Select Tables dialog box allowing you to change your selection of tables from the remote database. When you click OK, Update Schema will continue as described in the remaining steps below.
  6. Your database will now appear in the Data Sources Pane – click on the Data Sources tab to display this pane if it isn't already in view.

    A new window will also appear in the Workspace, showing a tree view of your database, looking something like this:

    Picture showing a tree view illustrating the structure of the remote database as displayed in the Workspace.

    At the top of the tree, the 'Data Source node' is the name you gave this Data Source and branching off below this are sub-nodes representing the various tables you have selected within the database. Double-click on a table node to display the column fields within that table. Double-click on the caption bar at the top of the list to hide the fields again. Alternatively, you can toggle the display of the column fields by clicking on the Arrow symbol to the right of the table name or right-clicking on the table name and choosing Expand from the context menu.

  7. You now need to tell your Project which column fields in the database you want to use. Each column name has a check box to the left of it. Select the check box for a column you want to include in your Project and the Data Mapping dialog box will appear:

    Picture showing the Data Mapping dialog box.

    This dialog box allows you to specify a default value for this data item within your app and to specify whether this is a key field or not.

    Click OK to add the data item or Cancel if you don't want to add it. If you choose OK the data item will be displayed in the Data Sources Pane below the name you assigned to this database. The data item trees displayed in the Data Sources Pane illustrate the database tables that will store the data on your mobile devices at runtime.

    You can map multiple data items within an individual table in one go. To do this, select the items in the standard manner by holding down the Ctrl or Shift keys whilst clicking on the required items (don't click on the check boxes) and then choose the Data Mappings button in the Data Source group on the Ribbon's Home tab. Choose Map Selected from the menu and the Data Mapping dialog box will be displayed with all your selected data items listed:

    Picture showing Data Mapping dialog box with multiple items.

    If you want to set default values or specify key fields, select a data item from the list and then edit the options for that item. If you want to apply the values specified in the selected item to all the other items listed in the dialog, click on the Apply to All button. You can also change the relative positions of the items using the Move Up and Move Down buttons.

    The Data Mappings menu also allows you to delete the currently selected data items from your mapped list and to map or remove all data items in the current table. Alternatively, you can access these options by right-clicking on a table.

    You don't have to map all the required data items at once. You can come back and add or delete mappings at any time. However, you won't be able to link a data item to a Control until you have mapped it as described above.

    You can view and edit your data mappings by displaying the Data Sources Pane and double-clicking on the Data Source name, right-clicking on the name and choosing Open or, if displayed, clicking on the window or tab for the Data Source window in the Workspace.

Clicking on a node in the tree view in the Data Sources Pane, will display the Properties for that node in the Properties Pane. Editable Properties are displayed in black. Those which can't be edited are displayed in grey. The main Properties are:

  • For ADO Database Data Sources you should have at least one Primary Key field specified, and this is essential if you want to update existing records in the remote database. You can specify multiple Primary Keys for an individual Data Source if necessary, in which case the combination of all Primary Keys must be unique for each record.
  • If the remote database is not a Microsoft SQL Server database, once you have configured your Data Source as described above, you must then set the SQL Type Property to ANSI SQL before you can download data from the remote database.
  • Once you have published an app you can change some of the above Properties, such as the Connection String, Username, Password and Timeout values, on the App Server using the App Manager utility allowing you to easily modify the connection details without having to edit your actual app. For example, you can use this feature to change between live and test data sources. You can also change these same values programmatically within your Scripts, allowing you to include connection options within an app.